<template>
    <div class="container_box">
        <vtextlabel ref= "vtla" :hotelData="hotelData" :parkData="parkData" :scenicSpotData="scenicSpotData" :scenicLoadData="scenicLoadData"></vtextlabel>
        <vnumlabel ref= "vnla"></vnumlabel>
        <viconlabel ref= "vcla" :hotelData="hotelData" :parkData="parkData" :scenicSpotData="scenicSpotData"></viconlabel>
    </div>
</template>

<script>
import vtextlabel from './components/vtextlabel.vue'
import vnumlabel from './components/vnumlabel.vue'
import viconlabel from './components/viconlabel.vue'
import { requestAPI } from '@/api/TYRequest'

export default {
    components: {
        vtextlabel,
        vnumlabel,
        viconlabel
    },
    created() {
    },
    data() {
        return {
            timer1: '',
            hotelData: [],
            parkData: [],
            scenicSpotData:[],
            scenicLoadData: []
        }
    },
    mounted() {
        this.timer1 = setInterval(this.getAllData, 30000000) 
        this.getAllData()
    },
    beforeDestroy() {
        clearInterval(this.timer1)
    },
    destroyed() {
    },
    methods: {
        getAllData(){
            // this.testCommonRequestFunc('/HotelLoad', 'get')
            requestAPI('/HotelLoad', 'get')
                .then(res => {
                    if (res.status === 200) {
                        const data = res.data
                        this.hotelData = data
                        this.$refs.vnla.flusData(data)
                        this.$refs.vcla.updateHotelIconPng(data)
                    }
                })
                .catch(err => {
                    console.log(err.message)
                })
            // this.testCommonRequestFunc('/ParkingLoad', 'get')
            requestAPI('/ParkingLoad', 'get')
                    .then(res => {
                        if (res.status === 200) {
                            const data = res.data
                            this.parkData = data
                            this.$refs.vcla.updateCarIconPng(data)
                            this.$refs.vnla.flushParkData(data)
                        }
                    })
                    .catch(err => {
                        console.log(err.message)
                    })
            // this.testCommonRequestFunc('/ScenicSpotCensus', 'get')
            requestAPI('/ScenicSpotCensus', 'get')
                    .then(res => {
                        if (res.status === 200) {
                            const data = res.data
                            this.scenicSpotData = data
                        }
                    })
                    .catch(err => {
                        console.log(err.message)
                    })
            // this.testCommonRequestFunc('/ScenicLoad', 'get')
            requestAPI('/ScenicLoad', 'get')
                    .then(res => {
                        if (res.status === 200) {
                            const data = res.data
                            this.scenicLoadData = data
                        }
                    })
                    .catch(err => {
                        console.log(err.message)
                    })
        }
    },

}
</script>

<style lang="less" scoped>

</style>
